package com.casstime.ec.cloud.meeting.web.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;

import com.casstime.ec.cloud.web.GenericWebMvcConfig;


@Configuration
@EnableWebMvc
public class WebMvcConfig extends GenericWebMvcConfig {
	
	@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/webapp/static/");
        super.addResourceHandlers(registry);
    }
	
	@Bean
    public FreeMarkerViewResolver freeMarkerViewResolver(IcecResourcesBean icecResourcesBean) {
        FreeMarkerViewResolver resolver = new FreeMarkerViewResolver();
        resolver.setPrefix("");
        resolver.setSuffix(".ftl");
        resolver.setContentType("text/html; charset=UTF-8");
        resolver.setRequestContextAttribute("request");
        resolver.setAttributesMap(icecResourcesBean.getResources());
        return resolver;
    }
}
